﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace App15._2
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        private delegate void WorkerThread();
        private delegate void WorkerThreadDelegate();

        public Window1()
        {
            InitializeComponent();
            WorkerThread worker = new WorkerThread(Worker);
            worker.BeginInvoke(null, null);
        }

        public void Worker()
        {
            textBlock.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, 
                new WorkerThreadDelegate(WorkerStart));
        }

        public void WorkerStart()
        {
            textBlock.Text = "Worker started!";
        }
    }
}
